<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        <!--  -->
        <button @click="fn1">修改数组某个值</button>
        <button @click="fn2">使用vur包裹后的方法</button>
        <button @click="fn3">使用非变更方法，例如过滤</button>

        <ul>
            <li v-for="item in allArr">{{item}}</li>
        </ul>
    </div>

    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el:'#app',
            data(){
                return{
                    allArr:['5ASA','1SDSSD','8RQQE']
                }
            },
            methods:{
                fn1(){
                    //js限制，无法检测数据中每个值的变化，所以修改了视图页不会更新
                    this.allArr[0]='assas'
                    // this.names.length = 0;
                },
                fn2(){
                    //vue把一些数组方法进行包裹，监听数组变化，会触发自动更新
                    this.allArr.sort()
                },
                fn3(){
                    //过滤后重新赋值给原数组，删除某个元素
                    this.allArr =  this.allArr.filter((item)=>{
                        return item !=="8RQQE"
                    })
                }
                
            }   
        })
    </script>
</body>
</html>